/**
 * ZNotice.java
 * com.zhihu.notify.model
 * Copyright (c) 2016, 北京聚智未来科技有限公司版权所有.
*/

package com.zhihu.notify.model;

import java.util.List;

import com.eova.common.base.BaseModel;

/**
 * 通知
 * @author   WXL
 * @Date	 2016年12月23日 	 
 */
public class ZNotice extends BaseModel<ZNotice> {

	/**
	 * TODO（用一句话描述这个变量表示什么）
	 */

	private static final long serialVersionUID = 2521091055686963125L;

	public static final ZNotice dao = new ZNotice();

	/**
	 * 通知 列表
	 */
	public List<ZNotice> queryAll(String userid) {
		String sql = "SELECT n.id,n.userid,n.createdate,"
				+ "(SELECT p.title from z_problem p WHERE p.id=n.problemid) as problemtitle,"
				+ "(SELECT u.nickname FROM c_user u WHERE u.id=n.senduserid) as sendname,"
				+ "n.status FROM z_notice n WHERE n.STATUS=1 and n.userid=? ORDER BY n.isRead asc,n.createDate DESC";
		return find(sql, userid);

	}

	public ZNotice queryNoRead(String userid) {
		String sql = "SELECT count(1) as cc from z_notice WHERE STATUS=1 and userid =? and isread=0";
		return findFirst(sql, userid);
	}

	/**
	 * 赞与感谢
	 */

	/**
	 * 关注
	 */

}
